<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        #logContent{
            font-size: 15px;
            font-family: "Lucida Console";
            resize: none;
            line-height: 1.5;
        }
        #field{
            font-size: 20px;
        }
        #lineNum{
            font-size: 20px;
        }
    </style>

    <script th:src="@{/webjars/jquery/3.3.1-2/jquery.min.js}"></script>
    <script type="text/javascript">

        $(function(){
            $("#lineNum").bind('keypress',function(event){
                if(event.keyCode == "13")
                {
                    change()
                }
            });
        });
        function change() {
            const domain = "/LOG/logCata";
            let lineNumber = $("input#lineNum").val();
            let logName = $("#field option:selected").val()
            if (lineNumber === undefined || Number(lineNumber) <= 0) {
                lineNumber = 50;
                $('#lineNum').val(lineNumber);
            }
            $.ajax({
                url: domain + "/" + logName + "/" + lineNumber,
                type: "GET",
                contentType: 'application/json;charset=utf-8',
                async: false,
                before: function () {
                  alert(this.url)
                },
                success: function (data) {
                    $("#logContent").text(data)
                },
                error: function (data) {
                    console.log("change room fail!");
                },
            });
        }
    </script>
</head>
<body>
    <h1>Tomcat/logs/:</h1>

    <h2>日志选择：</h2>
        <select id="field" class="field" onclick="change()" onchange="change()">
            <option value="">  --  日志列表 --  </option>
            <option th:each="log:${logList}" th:value="${log}" th:text="${log}"></option>
        </select>

    <h2>行数：</h2>
    <input id="lineNum" type="text" autocomplete="off">


    <h1>日志内容：</h1>
    <label for="logContent"></label>
    <textarea id="logContent" rows="50" cols="150" readonly font-size></textarea>
</body>
</html>